<?php
// $Id$

include_once('BaseModel.class.php');

class DefaultModel extends BaseModel
{
    function collect ($searchfield='', $searchtext='')
    {
        $searchtext = '%'.$searchtext.'%';
        $query = "SELECT * FROM user
                  WHERE LOWER($searchfield) LIKE LOWER('$searchtext')
                  ORDER BY 1";
        return $this->query($query, true);
    }

    function detail ($id)
    {
        $query = "SELECT * FROM user WHERE id='$id'";
        return $this->query($query, true);
    }

    /*
     * Add user and return the new user_id
     *
     */
    function add ($detail)
    {
        $this->insert('user', $detail);
        return $this->last_insert_id();
    }

    /*
     * Update user for a particular user_id
     *
     */
    function edit ($id, $detail)
    {
        return $this->update('user', $detail, "user_id = '$id'");
    }

    /*
     * Delete user detail for a particular user_id
     *
     */
    function deactivate ($id)
    {
        $query = "UPDATE user SET active = '0' WHERE id='$id'";
        return $this->query($query, false);
    }
    function activate ($id)
    {
        $query = "UPDATE user SET active = '1' WHERE id='$id'";
        return $this->query($query, false);
    }
}

?>
